const readline = require('readline');
const { add, sub, mul, div } = require('./jisuan');

const rl = readline.createInterface({
  input: process.stdin,//读取
  output: process.stdout,//屏幕显示
  prompt: '> '//提示输入
});

rl.on('line', input => {
  const trimmedInput = input.trim();//去掉空格防止误触
  if (trimmedInput === 'exit') {
    return rl.close();
  }

  
  const [op, a, b] = trimmedInput.split(' ');//分割成数组

  const num1 = Number(a);
  const num2 = Number(b);

  let re;
    switch (op) {
      case '+':
        re = add(num1, num2);
        break;
      case '-':
        re = sub(num1, num2);
        break;
      case '*':
        re = mul(num1, num2);
        break;
      case '/':
        re = div(num1, num2);
        break;
        return;
    }
    console.log('=', re);

  rl.prompt();
});

rl.prompt();